package test;

import java.util.Scanner;

/**
 * 输入年月日 每行空格隔开 年 月 日  ,输出这是一年中的第几天
 *
 */
public class test08 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        String[] ymd = str.split(" ");

        Integer year = Integer.valueOf(ymd[0]);
        Integer month = Integer.valueOf(ymd[1]);
        Integer day = Integer.valueOf(ymd[2]);
        int days = getDay(year,month,day);

       /* int year = scan.nextInt();
        int month = scan.nextInt();
        int day = scan.nextInt();*/


    }
    static int getDay(int year, int month, int day) {
        int sum = 0;
        switch (month) {
            case 12:
                sum += 30;
            case 11:
                sum += 31;
            case 10:
                sum += 30;
            case 9:
                sum += 31;
            case 8:
                sum += 31;
            case 7:
                sum += 30;
            case 6:
                sum += 31;
            case 5:
                sum += 30;
            case 4:
                sum += 31;
            case 3:
                //sum += 31;
                if ((year % 4 ==0) && (year % 100 == 0) || (year % 400 == 0)){
                    sum += 29;
                }else {
                    sum += 28;
                }
            case 2:
                sum += 31;
            case 1:
                sum += day;
        }
        System.out.println(sum);
        return sum;
    }



}
